cmake_minimum_required(VERSION 2.6)

project(giflib)

set( SOURCE_FILES 
    lib/dev2gif.c
    lib/dgif_lib.c
    lib/egif_lib.c
    lib/getarg.c
    lib/gif_err.c
    lib/gif_font.c
    lib/gif_hash.c
    lib/gifalloc.c
    lib/qprintf.c
    lib/quantize.c
)

set( HEADER_FILES
    lib/getarg.h
    lib/gif_hash.h
    lib/gif_lib.h
    lib/gif_lib_private.h
)

add_library( giflib ${SOURCE_FILES} ${HEADER_FILES} )
set_target_properties( giflib PROPERTIES COMPILE_DEFINITIONS "_LIB;_OPEN_BINARY;HAVE_IO_H;HAVE_FCNTL_H;HAVE_STDARG_H;HAVE_BASETSD_H;HAVE_SYS_TYPES_H" )
set_target_properties( giflib PROPERTIES DEBUG_POSTFIX "d" )

#install
install( FILES ${HEADER_FILES} DESTINATION include COMPONENT giflib-dev)
install( TARGETS giflib ARCHIVE DESTINATION lib COMPONENT giflib-dev)

# giftext executable to test giflib
include_directories( lib )
add_executable( giftext util/giftext.c )
target_link_libraries( giftext giflib )
install( TARGETS giftext RUNTIME DESTINATION bin COMPONENT giflib)
